package showBooks.service;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionTest {
    private static Connection con= null;
    public static java.sql.Connection getConnection(){
        try {
            //连接数据库
            Class.forName("com.mysql.cj.jdbc.Driver");

            String url = "jdbc:mysql://localhost:3306/mydata";
            con = DriverManager.getConnection(url,"root","123456");

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e){
            e.printStackTrace();
        }
        return con;
    }



}